<? session_start();
    include('conn.php');
    include('protect.php');
	include('gettopmenu.php');
   	error_reporting(0);

	$dt=date("d-m-Y");
    $dt1=date("d-m-Y");
	$msg='';
	
	?>
	   <style type="text/css">
<!--
.style1 {font-size: 18px}
.style4 {font-size: 14}
.style5 {
	color: #666666;
	font-style: italic;
	font-weight: bold;
}
.style6 {
	font-size: 18px;
	font-style: italic;
	font-weight: bold;
}
-->
           </style>
	<?php
	if(!isset($_REQUEST['flag']))
{
$show=1;
$tranid=$_REQUEST['tranid'];

}     

else if($_REQUEST['flag']==1)
{   
$show=2;
$tranid=$_REQUEST['tranid'];
$trndetid=$_REQUEST['trndetid'];


} // flag==1	

else if($_REQUEST['flag']==2)
{   
$show=2;
$tranid=$_REQUEST['tranid'];
$trndetid=$_REQUEST['trndetid'];


		$bankdate=$_REQUEST['datepicker3'];
		$pnr=$_REQUEST['pnr'];
		$sector=$_REQUEST['sector'];
		$tax=$_REQUEST['tax'];
		$travelDate=$_REQUEST['paydate'];
        $returnDate=$_REQUEST['returndate'];
		$basic=$_REQUEST['basic'];
		$admamt=$_REQUEST['admamt'];
		$idnumber=$_REQUEST['idnumber'];
		$ticket=$_REQUEST['ticket'];
		$pax=$_REQUEST['pax'];
		//$amount=$_REQUEST['pax'];
	
	$amount=$tax+$admamt+$basic;


$bd=explode("-", $bankdate);  //format date-month-year will the format year-month-date
$bankdate=$bd[2].'-'.$bd[1].'-'.$bd[0];

$td=explode("-", $travelDate);  //format date-month-year will the format year-month-date
$travelDate=$td[2].'-'.$td[1].'-'.$td[0];


$rd=explode("-", $returnDate);  //format date-month-year will the format year-month-date
if(count($rd) == 3)
	$returnDate=$rd[2].'-'.$rd[1].'-'.$rd[0];
else
	$returnDate='NULL';


// $QmastDebit=mysql_fetch_array(mysql_query("select  debitamt from transactionmast where trnid='$tranid' "));
// $QDetailsAmt=mysql_fetch_array(mysql_query("select Amount from transactiondetails where trndetid='$trndetid' and tranid='$tranid'   "));

// $AfterSubstractDebitAmt=$QmastDebit['debitamt']-$QDetailsAmt['Amount'];

// $currentdebitAmt=$AfterSubstractDebitAmt+$amount;


	$rdlen = strlen($returnDate);
	
	if(($pnr!='') AND ($sector!='') AND ($idnumber!=''))
	{ // if(($pnr!='') AND ($sector!='') AND ($idnumber!='')) [starts]
	 
	$UpdateQ=mysql_query("
	update transactiondetails set 
	`Bkng Date`='$bankdate',`ID Number`='$idnumber',`Pax Name`='$pax',`Ticket Number`='$ticket',PNR='$pnr',Sector='$sector',`Travel Date`='$travelDate',`Return Date`=case when $rdlen > 2 then '$returnDate' else NULL end,
	Basic='$basic',Tax='$tax',Admincharges='$admamt',Amount='$amount' where trndetid='$trndetid' and tranid='$tranid'
	
");


 $QTransDetailsSumAmt=mysql_fetch_array(mysql_query("select sum(Amount) SumAmount from transactiondetails where tranid='$tranid'   "));
 $QTransDetailsSumAmt_var = $QTransDetailsSumAmt['SumAmount'];
 
//update transactionmast set creditamt = case when bid = 15 then  4567 else creditamt end where trnid=5202
 $qUpdateTmast=mysql_query(" update transactionmast set creditamt = case when bid = 15 then '$QTransDetailsSumAmt_var' else creditamt end  where trnid='$tranid' ");
  $qUpdateTmast=mysql_query(" update transactionmast set debitamt = case when bid != 15 then '$QTransDetailsSumAmt_var' else debitamt end  where trnid='$tranid' ");
 
 
 
	if($UpdateQ)
		{
		?>	
       <script>window.location.href = 'ViewTransactionDetails.php?flag=1&tranid=<?php echo $tranid; ?>&trndetid=<?php  echo $trndetid; ?>'</script>

           		
        <? 			
		}
	
	}// if(($pnr!='') AND ($sector!='') AND ($idnumber!='')) [starts]
	
	else
	{ ?>
	<script>window.location.href = 'ViewTransactionDetails.php?flag=1&tranid=<?php echo $tranid; ?>&trndetid=<?php  echo $trndetid; ?>'</script>
	<?php
	}
	
} // flag==1	


else if($_REQUEST['flag']==3)
{   
$show=1;
$tranid=$_REQUEST['tranid'];
$trndetid=$_REQUEST['trndetid'];
//$Qdel=


$Qdel=mysql_query(" delete from transactiondetails where trndetid='$trndetid' and tranid='$tranid' ");

//echo " select *  from transactiondetails where trndetid='$trndetid' and tranid='$tranid' ";


	if($Qdel)
		{
		?>	
    <script>window.location.href = 'ViewTransactionDetails.php?tranid=<?php echo $tranid; ?>'</script>
	      <? 			
		}
		
	else
	{ ?>
	<script>window.location.href = 'ViewTransactionDetails.php?tranid=<?php echo $tranid; ?>'</script>
	<?php
	}
	
} // flag==3	


?>



<!--code for paging // first portion -->
<?php

/*** Purpose : To display records by paging ***/
//Set the page size
$PageSize = 10;
$StartRow = 0;

//Set the page no
if(empty($_GET['PageNo'])){
    if($StartRow == 0){
        $PageNo = $StartRow + 1;
    }
}else{
    $PageNo = $_GET['PageNo'];
    $StartRow = ($PageNo - 1) * $PageSize;
}

//Set the counter start
if($PageNo % $PageSize == 0){
    $CounterStart = $PageNo - ($PageSize - 1);
}else{
    $CounterStart = $PageNo - ($PageNo % $PageSize) + 1;
}

//Counter End
$CounterEnd = $CounterStart + ($PageSize - 1);
?>
<style type="text/css">
.textst{ color:#666666; font-family: Arial, Helvetica, sans-serif; font-size:14px; font-weight:700}
</style>
 <script type="text/javascript" src="main.js"></script>
 
 <!--Added by jack for auto calculation-->
<!-- <script type="text/javascript" src="scrpts/jquery.validate.js"></script>
<script type="text/javascript" src="scrpts/jquery-1.8.0.min.js"></script> !-->

<!--Added by jack for auto calculation-->
  
  <!--For delete starts-->


<script LANGUAGE="JavaScript">
<!--
// Nannette Thacker http://www.shiningstar.net
function confirmSubmit()
{
var agree=confirm("Do you really want to delete ?");
if (agree)
	return true ;
else
	return false ;
}
// -->
</script>

<!--For delete ends-->
  
 <script language="javascript">
       $(function() {
               $("#datepicker3").datepicker({ dateFormat: "dd-mm-yy" }).val();
			   $("#datepicker4").datepicker({ dateFormat: "dd-mm-yy" }).val();
               $("#paydate").datepicker({ dateFormat: "dd-mm-yy" }).val();	
               $("#returndate").datepicker({ dateFormat: "dd-mm-yy" }).val();    
       });
	  function chkamt()
	  {
	  	document.frmtran.balamount.value=document.frmtran.dramount.value-document.frmtran.cramount.value;
	  } 
	
 //   function chkpay()
  //    {
//		if (document.frmtran.payid.value==2)
//		{
//			document.getElementById('bankid').disabled = false;
//			document.getElementById('branch').disabled = false;
//		}
//		else
//		{
//			document.getElementById('bankid').disabled = true;
//			document.getElementById('branch').disabled = true;
//		}
//	  }

    function chkdramt()
      {
    	if (document.frmtran.dramount.value>0)
		{
			document.getElementById('bankid').disabled = true;
			document.getElementById('branch').disabled = true;
            document.getElementById('paydate').disabled = true;
            document.getElementById('payid').disabled = true;
		}
		else
		{
			document.getElementById('bankid').disabled = false;
			document.getElementById('branch').disabled = false;
            document.getElementById('paydate').disabled = false;
            document.getElementById('payid').disabled = false;
		}
	  }

 function chkcramt()
      {
        if (document.frmtran.cramount.value>0)
		{
			document.getElementById('bankid').disabled = false;
          	document.getElementById('branch').disabled = false;
            document.getElementById('paydate').disabled = false;
            document.getElementById('payid').disabled = false;
		}
		else
		{
			document.getElementById('bankid').disabled = true;
			document.getElementById('branch').disabled = true;
            document.getElementById('paydate').disabled = true;
            document.getElementById('payid').disabled = true;
		}
	  }


	  function validatefrm()
	  {
		if (document.frmtran.payid.value==2)
		{
			if (document.frmtran.bankid.value==1)
			{
				alert("select Bank name");
				document.frmtran.bankid.focus();
				return false;
			}	
			if (document.frmtran.paydate.value=="")
			{
				alert("select Pay Date");
				document.frmtran.paydate.focus();
				return false;
			}	
			if (document.frmtran.branch.value=="")
			{
				alert("Enter Branch Name");
				document.frmtran.branch.focus();
				return false;
			}	
		}	
	  }
    function chgd()
	{
	  	//alert(document.frmtran.custid.value);
		var a=document.frmtran.custid.value;
		if(a.substring(0,1)=="i")
		{
			document.frmtran.sid.disabled = false;
		}
		else
		{
			document.frmtran.sid.disabled = true;
		}
		if(a.substring(0,1)=="c")
		{
			document.getElementById('ct').innerHTML="Customer";
		}
		if(a.substring(0,1)=="i")
		{
			document.getElementById('ct').innerHTML="Distributor";
		}
		if(a.substring(0,1)=="d")
		{
			document.getElementById('ct').innerHTML="Agent";
		}
         if(a.substring(0,1)=="r")
        {
			document.getElementById('ct').innerHTML="Corporate";
		}
	} 
 </script>
 <?php 
 
 $qry1 = "SELECT A.trnid,A.trndate,A.invoicenumber TinvoiceNum,B.bdesc,C.catdesc ,D.custdesc, D.custtype,E.subname,A.debitamt,A.creditamt,F.bankname,A.branchname,A.remarks,A.paydate,A.enteredby,G.pdesc
FROM transactionmast A, businessmast B,categorymast C, customermast D, subdealermast E, bankmast F, paymentmast G
where A.bid=B.bid and A.catid=C.catid and A.custid=D.custid and A.subid=E.subid and A.bankid=F.bankid and A.payid=G.payid and A.trnid ='".$tranid."'";// order by A.trnid desc";

$r1=mysql_fetch_array(mysql_query($qry1)); 

$invoiceNumber=$r1['TinvoiceNum'];

 ?>
 
<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Transaction / Add Transaction</label></td>
<div  align="center">
	<div  ng-controller="MyCtrl">
	<div align="center">
	<table width="1300"  border="0" align="center" bgcolor="#E0EBED" >
	
	<tr bgcolor="#E0EBED"><td>
	<table width="1254" border="0" class="des" >
		<tr bgcolor="#f5f5f5" ><td colspan="7" ><span class="style1"><br>
              <strong>Details Of Master Transaction NO   <?php echo $tranid; ?>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [CLIENT : <?php echo $r1['custdesc']; ?>] </strong></span><br><br></td>
			  
			  <td colspan="7" ><span class="style1"><span class="style5">Search By Trans Details</span> No: 
		      <input name="tdno" type="text"  id="tdno"/>
			  
			  <input type="hidden" name="tranid" id="tranid" value="<?php echo $tranid; ?>">
			  </span><br>
			  <br></td>
	</tr>
  <tr>
 
 
    <td width="102" bgcolor="EBE9E9"><span class="style4"><strong>Type</strong></span></td>
   
    <td width="113" bgcolor="EBE9E9"><span class="style4"><strong>Business</strong></span></td>
    <td width="82" bgcolor="EBE9E9"><strong>Category</strong></td>
    <td width="135" bgcolor="EBE9E9"><span class="style4"><strong>Sub-Agent Name </strong></span></td>
	
    <td width="63" bgcolor="EBE9E9"><span class="style4"><strong>Debit</strong></span></td>
    <td width="64" bgcolor="EBE9E9"><span class="style4"><strong>Credit</strong></span></td>
    <td width="125" bgcolor="EBE9E9"><strong>Bank</strong></td>
    <td width="131" bgcolor="EBE9E9"><strong>Branch</strong></td>
	<td width="158" bgcolor="EBE9E9"><strong>Pay Date</strong></td>
    <td width="134" bgcolor="EBE9E9"><strong>Payment Method </strong></td>
    <td width="158" bgcolor="EBE9E9"><strong>Remarks</strong></td>
    <td width="36" bgcolor="EBE9E9"><strong> Pax Count</strong></td>
    
    <td width="26" bgcolor="EBE9E9">&nbsp;</td>
    <td width="31" bgcolor="EBE9E9">&nbsp;</td>
    </tr>

  <?php 
 
 
 
 $DC=mysql_fetch_array(mysql_query(" select count(tranid) as c from transactiondetails where tranid='$tranid' ")); 
 $color='#F9F8F8';

  ?>
 
  <tr bgcolor="<?php echo $color; ?>">
   
	
    <td style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[custtype]"?></td>
    <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[bdesc]"?></td>
    <td style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[catdesc]"?></td>
 
    <td style="border-right:  solid 1px #CCCCCC" ><?php echo $r1['subname']; ?></td>
    <td style="border-right:  solid 1px #CCCCCC"><?php echo $r1['debitamt']?></td>
    <td style="border-right:  solid 1px #CCCCCC"><?php echo $r1['creditamt'] ?></td>
    <td style="border-right:  solid 1px #CCCCCC"><?php echo $r1['bankname'] ?></td>
    <td style="border-right:  solid 1px #CCCCCC"><?php echo $r1['branchname'] ?></td>
    <td style="border-right:  solid 1px #CCCCCC"><?php echo $r1['paydate'] ?></td>
    <td style="border-right:  solid 1px #CCCCCC"><?php echo $r1['pdesc'] ?></td>
    <td style="border-right:  solid 1px #CCCCCC"><?php echo $r1['remarks'] ?></td>
    <td style="border-right:  solid 1px #CCCCCC"><?php echo $DC['c'] ?></td>
    
    <td style="border-right:  solid 1px #CCCCCC">
	<?php if(($invoiceNumber==0) OR ($invoiceNumber=='')) { ?>
	<form method="post" action="TransactionDetails.php">
	<input name="submit" type="image" src="images/detail.png" />
	<input name="flag" type="hidden" value="<?php echo 1;?>" />
	<input name="tranid" type="hidden" value="<?php echo $tranid;?>" />
	
	
	</form>	<?php  } ?>	</td>
    <td style="border-right:  solid 1px #CCCCCC">
	<?php if($DC['c']>0) {

	
	?>
	<form method="post" action="ViewTransactionDetails.php">
<input name="submit" type="image" src="images/view.png"/>
	
	<input name="tranid" type="hidden" value="<?php echo $tranid;?>" />
	</form>
	<?php  } ?>	</td>
    </tr>
</table>



	<div id="TdView">
	<?php $qTDCH="SELECT count(*) as c FROM transactiondetails where tranid='$tranid'  ";
//echo $qTDCH; 

$tdQ=mysql_fetch_array(mysql_query($qTDCH)); 

if($tdQ['c']>0)
{ // if($tdQ['c']>0) 

?>
	
	<table width="1254" border="1" bordercolor="#666666" class="des">
	 <tr>
  <td bgcolor="#fff" colspan="15" align="center"><br>
    <I><font color="#666666" size="5">Transaction Details against Master transaction No : <?php echo $tranid; ?></font></I>
    <br><?php  if($show==3)
	echo "<font color='green'>Successfully deleted!</font>";
	?></td>
  </tr>
  
  <tr>
   <td width="45" bgcolor="#EBE9E9"><span class="style4"><strong>T.D NO</strong></span></td>
   <td width="131" bgcolor="#EBE9E9"><span class="style4"><strong>Booking Date</strong></span></td>
   <td width="167" bgcolor="#EBE9E9"><span class="style4"><strong>ID Number</strong> </span></td>
   
    <td width="80" bgcolor="#EBE9E9"><span class="style4"><strong>PAX</strong></span></td>
    <td width="117" bgcolor="#EBE9E9"><span class="style4"><strong>Ticket Number </strong></span></td>
    <td width="71" bgcolor="#EBE9E9"><span class="style4"><strong>PNR</strong></span></td>
    <td width="76" bgcolor="#EBE9E9"><span class="style4"><strong>SECTOR</strong></span></td>
    <td width="108" bgcolor="#EBE9E9"><span class="style4"><strong>Travel Date</strong></span></td>
    <td width="108" bgcolor="#EBE9E9"><span class="style4"><strong>Return Date</strong></span></td>
    <td width="83" bgcolor="#EBE9E9"><span class="style4"><strong>Basic</strong></span></td>
	<td width="64" bgcolor="#EBE9E9"><span class="style4"><strong>TAX</strong></span></td>
	<td width="97" bgcolor="#EBE9E9"><span class="style4"><strong>Admin Charge</strong> </span></td>
	<td width="93" bgcolor="#EBE9E9"><span class="style4"><strong>Amount</strong></span></td>
	<td width="17" bgcolor="#EBE9E9">&nbsp;</td>
	<td width="17" bgcolor="#EBE9E9">&nbsp;</td>
  </tr>
  
  <?php
   $Qinv=mysql_fetch_array(mysql_query(" select invoicenumber from transactionmast where trnid='$tranid' "));
 $TRecord = mysql_query(" SELECT trndetid,tranid,`Bkng Date` Bkng_Date,`ID Number` ID_Number,`Pax Name`Pax_Name, `Ticket Number` Ticket_Number,PNR, 
Sector,`Travel Date` Travel_Date,`Return Date` Return_Date,Basic,Tax,Admincharges,Amount FROM transactiondetails ");

 $q1 = mysql_query(" SELECT trndetid,tranid,`Bkng Date` Bkng_Date,`ID Number` ID_Number,`Pax Name`Pax_Name, `Ticket Number` Ticket_Number,PNR, 
Sector,`Travel Date` Travel_Date,`Return Date` Return_Date,Basic,Tax,Admincharges,Amount FROM transactiondetails where tranid='$tranid'  ORDER BY trndetid asc  LIMIT $StartRow,$PageSize");

 //Total of record
 $RecordCount = mysql_num_rows($TRecord);

 //Set Maximum Page
 $MaxPage = $RecordCount % $PageSize;
 if($RecordCount % $PageSize == 0){
    $MaxPage = $RecordCount / $PageSize;
 }else{
    $MaxPage = ceil($RecordCount / $PageSize);
 }
?>
  <?php //print "$RecordCount record(s) founds - You are at page $PageNo  of $MaxPage" ?>	
  <?php
$i = 1;
while ($r1 = mysql_fetch_array($q1, MYSQL_NUM)) {
    $bil = $i + ($PageNo-1)*$PageSize;
?>

  <?php 
  

 
 if($i%2==0)
 $color='#E7F8FB';
 else 
 $color='#F9F8F8';
 
  ?>
 
  <tr bgcolor="<?php echo $color; ?>">
     <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[0] "?></td>
    <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[2] "?></td>
	
    <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[3]"?></td>
    <td  style="border-right:  solid 1px #CCCCCC" ><?php echo "$r1[4]"?></td>
    <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[5]"?></td>
	 <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[6]"?></td>
	  <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[7]"?></td>
	   <td  style="border-right:  solid 1px #CCCCCC" ><?php echo "$r1[8]"?></td>
	    <td  style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[9]"?></td>
		 <td   style="border-right:  solid 1px #CCCCCC"><?php echo "$r1[10]"?></td>
		  <td  style="border-right:  solid 1px #CCCCCC" ><?php echo "$r1[11]"?></td>
		   <td  style="border-right:  solid 1px #CCCCCC" ><?php echo "$r1[12]"?></td>
            <td  style="border-right:  solid 1px #CCCCCC" ><?php echo "$r1[13]"?></td>
   
    <td  style="border-right:  solid 1px #CCCCCC">
		<?php if(($invoiceNumber==0) OR ($invoiceNumber=='')) { ?>
	<form method="post" action="ViewTransactionDetails.php">
	<input name="submit"   type="image" src="images/edit2.png" width="15" height="15"  />
	<input name="flag" type="hidden" value="<?php echo 1;?>" />
	<input name="tranid" type="hidden" value="<?php echo $tranid;?>" />
		<input name="trndetid" type="hidden" value="<?php echo $r1['0'];?>" />
	
	
	</form>	<?php } ?>	</td>
    <td  style="border-right:  solid 1px #CCCCCC">
		<?php if(($invoiceNumber==0) OR ($invoiceNumber=='')) { ?>
	<form method="post" action="ViewTransactionDetails.php" >
	<input name="submit"   type="image" src="images/del.png" width="15" height="15"   onclick="return confirmSubmit()"  />
	<input name="flag" type="hidden" value="<?php echo 3;?>" />
	<input name="tranid" type="hidden" value="<?php echo $tranid;?>" />
		<input name="trndetid" type="hidden" value="<?php echo $r1['0'];?>" />
	
	</form>
		<?php } ?>	
	</td>
  </tr>
 
  <?php  
  
   $i++; } ?>
   
   <tr bgcolor="#FFFFFF">
   <td colspan="15"><?php
        //Print First & Previous Link is necessary
        if($CounterStart != 1){
            $PrevStart = $CounterStart - 1;
            print "<a href=ViewTransactionDetails.php?PageNo=1&tranid=$tranid><font color='black'>First</font> </a>: ";
            print "<a href=ViewTransactionDetails.php?PageNo=$PrevStart&tranid=$tranid><font color='black'>Previous </font></a>";
        }
        print " [ ";
        $c = 0;

        //Print Page No
        for($c=$CounterStart;$c<=$CounterEnd;$c++){
            if($c < $MaxPage){
                if($c == $PageNo){
                    if($c % $PageSize == 0){
                        print "$c ";
                    }else{
                        print "$c ,";
                    }
                }elseif($c % $PageSize == 0){
                    echo "<a href=ViewTransactionDetails.php?PageNo=$c&tranid=$tranid><font color='black'>$c</font></a> ";
                }else{
                    echo "<a href=ViewTransactionDetails.php?PageNo=$c&tranid=$tranid><font color='black'>$c</font></a> ,";
                }//END IF
            }else{
                if($PageNo == $MaxPage){
                    print "$c ";
                    break;
                }else{
                    echo "<a href=ViewTransactionDetails.php?PageNo=$c&tranid=$tranid><font color='black'>$c</font></a> ";
                    break;
                }//END IF
            }//END IF
       }//NEXT

      echo "] ";

      if($CounterEnd < $MaxPage){
          $NextPage = $CounterEnd + 1;
          echo "<a href=ViewTransactionDetails.php?PageNo=$NextPage&tranid=$tranid><font color='black'>Next</font></a>";
      }
      
      //Print Last link if necessary
      if($CounterEnd < $MaxPage){
       $LastRec = $RecordCount % $PageSize;
        if($LastRec == 0){
            $LastStartRecord = $RecordCount - $PageSize;
        }
        else{
            $LastStartRecord = $RecordCount - $LastRec;
        }

        print " : ";
        echo "<a href=ViewTransactionDetails.php?PageNo=$MaxPage&tranid=$tranid><font color='black'>Last</font></a>";
        }
      ?></td>
   </tr>
</table> 


<?php } else
echo "<font color='red'><I>No Transaction Details found Against transaction Master No $tranid</I></font>";

?>
 </div>
	</td></tr>
	
	
	
	</table>
	<?php if($show==2) {
	
	 $eq=mysql_fetch_array(mysql_query(" SELECT trndetid,tranid,`Bkng Date` Bkng_Date,`ID Number` ID_Number,`Pax Name`Pax_Name, `Ticket Number` Ticket_Number,PNR, 
Sector,`Travel Date` Travel_Date,`Return Date` Return_Date,Basic,Tax,Admincharges,Amount FROM transactiondetails   where tranid='$tranid' and trndetid='$trndetid'  ")); 
	 
	
	
	// date formma change
	$bd1=explode("-", $eq['Bkng_Date']);  //format year-month-day will the format day-month-year
$bankdateData=$bd1[2].'-'.$bd1[1].'-'.$bd1[0];


$td1=explode("-", $eq['Travel_Date']);  //format date-month-year will the format year-month-date
$travelDateData=$td1[2].'-'.$td1[1].'-'.$td1[0];


$rd1=explode("-", $eq['Return_Date']);  //format date-month-year will the format year-month-date
$returnDateData=$rd1[2].'-'.$rd1[1].'-'.$rd1[0];	
	 
	?>
	
	<FORM METHOD="post" name="frmtran" action="ViewTransactionDetails.php" onsubmit="return validatefrm();">
			<table  cellpadding="4" id="box-table-a" cellspacing="4" border="1" width="874" bgcolor="#000000" style="background-color:#DFEBF9;">
				<tr><td colspan="6" align="center" height="30" style="text-align:center; color:#FF0000;"><?=$msg?></td></tr>
				<tr>
				  <td colspan="6" align="center" height="30" style="text-align:center;font-size:14px; color:#333333; font-weight:bold; ">Upadate Transaction Details Entry against Tran ID <?php echo $tranid; ?></td>
				</tr>
				<tr bgcolor="#FFFFFF">
				  <td width="149"><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Booking Date  </label></td>
				  <td width="9"><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td width="272" style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<input type="text" required= ""  id="datepicker3" name="datepicker3" class="smallInput" value="<?php echo $bankdateData; ?>" />				  </td>
				<td width="99" ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">ID Number </label></td>
				  <td width="5" ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td width="250"  style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<input type="text" required= ""  id="idnumber" name="idnumber" class="smallInput" value="<?php echo $eq['ID_Number']?>" />				  </td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Pax Name</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<input type="text" required= ""  id="pax" name="pax" class="smallInput"  value="<?php echo $eq['Pax_Name']?>" />					</td>
				  <td width="99" ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Ticket Number</label></td>
				  <td width="5" ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td width="250"  style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<input type="text" required= ""  id="ticket" name="ticket" class="smallInput"  value="<?php echo $eq['Ticket_Number']?>"/>				  </td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">PNR</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<p>
						  <input type="text" required= ""  id="pnr" name="pnr" class="smallInput"  value="<?php echo $eq['PNR']?>" />
					  </p>
					<p>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;"> SECTOR </label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<input type="text" required= ""  id="sector" name="sector" class="smallInput"   value="<?php echo $eq['Sector']?>"/>					</td>
				</tr>
				
											
				<tr bgcolor="#fff">
    			<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Travel Date</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<input type="text" required= ""  id="paydate" name="paydate" class="smallInput" 	 value="<?php echo $travelDateData; ?>"/>    				</td>
                        <td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Return Date</label></td>
    				<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<input type="text"   id="returndate" name="returndate" class="smallInput"      value="<?php echo $returnDateData; ?>"/>    					</td>
                        </tr>
            
				 
				<tr bgcolor="#FFFFFF">
                 <td width="99" ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Basic</label></td>
    			  <td width="5" ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td width="250"  style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<input type="text" required= ""  id="basic" name="basic" class="smallInput" value="<?php echo $eq['Basic']?>" />				  </td>
				
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Tax</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<p>
						  <input type="text" required= ""  id="tax" name="tax" class="smallInput"  value="<?php echo $eq['Tax']?>" />
					  </p>
					<p>
				</tr>
				
				
				<tr bgcolor="#FFFFFF">
                    <td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;"> Admin Charges </label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
					<input type="text" required= ""  id="admamt" name="admamt" class="smallInput"  value="<?php echo $eq['Admincharges']?>"			</td>
				                    
					<td><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Amount</label></td>
					<td><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<p>
				  	  <div id="admincharcges"><input type="text"   id="amount" name="amount" class="smallInput"  disabled="disabled" value="<?php echo $eq['Amount']?>"/></div>	
					  </p>
					<p>
                                  
                    </td>
					</tr>
				
				<tr>
					<td align="center" colspan="6" style="background-color:#BBE2EE">
						<input type="submit"  name="submit" value="Update Record" />	
						<input type="hidden"  name="flag" value="<?php echo 2;?>" />	
						<input type="hidden"  name="tranid" value="<?php echo $tranid;?>" />	
						<input type="hidden"  name="trndetid" value="<?php echo $trndetid;?>" />	
				  </td>
				</tr>
			</table>
	  </FORM>
			
			<?php  } ?>
	
	</div>

</div>
</div>
</body>
</html>


<script type="text/javascript">

	$("#basic,#tax,#admamt").keyup(function(){
		$.ajax({
			type: "GET",
			url: "adminch.php",
			data: "basic="+$("#basic").val()+"&tax="+$("#tax").val()+"&admamt="+$("#admamt").val(),
			success:function(result){				
    			$("div#admincharcges").html(result);
			}	
		
		});
	});
	


$("#tdno").keyup(function(){
		$.ajax({
			type: "GET",
			url: "ajx/transDetails.php",
			data: "tdno="+$("#tdno").val()+"&tranid="+$("#tranid").val(),
			success:function(result){				
    			$("div#TdView").html(result);
			}	
		
		});
	});

	</script>